package com.explorex.infra.puma.adaptor;

import com.alibaba.fastjson2.JSON;
import com.explorx.puma.common.rpc.RpcResponse;
import com.explorx.puma.common.rpc.RpcResponseUtils;
import com.explorx.sns.puma.im.api.ImSendService;
import com.explorx.sns.puma.im.api.dto.SendImMsgReq;
import com.explorx.sns.puma.im.api.dto.SendImMsgResp;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

@Service
public class LongLinkImAdaptor {

    @DubboReference(version = "1.0.0", timeout = 1000)
    private ImSendService imSendService;

    public boolean dispatchMessage(String userId, byte[] body){
        SendImMsgReq req=new SendImMsgReq();
        JSON.parseObject(body,SendImMsgReq.class);
        final SendImMsgResp resp = imSendService.sendMessage(req);
        return RpcResponseUtils.isSuccess(resp);
    }


}
